package com.myblog.controller;


import com.myblog.pojo.User;
import com.myblog.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    private static Logger log = LoggerFactory.getLogger(UserController.class);

    @RequestMapping("test")
    public String queryUserById(@RequestParam("id") String id, Model model) {
        User user = null;
        try{
            user = userService.queryUserById(id);
        } catch (Exception e) {
            log.debug("获取到的user内容为{}", user);
        }
        model.addAttribute("user", user);
        return "test";

    }

}
